<template>
	<view class="store">
		<view class="head" :style="{height: pHeight + tHeight + 'px'}">
			<view class="xztitle" :style="[{height: pHeight + 'px', top: tHeight + 'px',lineHeight: pHeight + 'px'}]">
				分成记录
				<view class="iconfont icon-dayuhao1" @click="fanhui"></view>
			</view>
		</view>
		<view class="headtop clearfix" :style="{marginTop: pHeight + tHeight + 'px'}"></view>
		<view class="nr">
			<view class="list">
				<view class="liebiao clearfix">
					<view class="left fl">签约时间：</view>
					<view class="right fl">
						<view class="title">{{info.created_at}}</view>
					</view>
				</view>
				<view class="liebiao clearfix">
					<view class="left fl">操作人：</view>
					<view class="right fl">
						<view class="title" v-if="info.staff">{{info.staff}}</view>
						<view class="title" v-else-if="info.agents">{{info.agents}}</view>
						<view class="title" v-else>平台管理员</view>
					</view>
				</view>
				<view class="liebiao clearfix">
					<view class="left fl">合作时间：</view>
					<view class="right fl">
						<view class="title">{{info.endtime}}</view>
					</view>
				</view>
				<view class="liebiao clearfix">
					<view class="left fl">充电宝分成比例：</view>
					<view class="right fl">
						<view class="name">{{info.divided}}%</view>
					</view>
				</view>
				<view class="liebiao clearfix">
					<view class="left fl">充电线分成比例：</view>
					<view class="right fl">
						<view class="name">{{info.dividedline}}%</view>
					</view>
				</view>
				<view class="liebiao clearfix">
					<view class="left fl">盒子分成比例：</view>
					<view class="right fl">
						<view class="name">{{info.dividedbox}}%</view>
					</view>
				</view>
			</view>
			<view class="footer clearfix">
				<view class="left fl" @click="tingzhi">结束分成</view>
				<view class="right fr" @click="topage('/subpackageA/store/editdivide?bussinid=' + bussinid)">修改比例</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				baseUrl: getApp().globalData.baseUrl,
				headerTop: 0,
				pHeight: 0,
				tHeight: 0,
				bussinid: '',
				info: {
					created_at: '',
					staff: '',
					agents: '',
					endtime: '',
					divided: '',
					dividedline: '',
					dividedbox: '',
				}
			}
		},
		onLoad(options) {
			// 头部距离
			let res = uni.getSystemInfoSync() ///微信api方法
			let titleH;
			if (res && res['system']) {
				// 判断是否是安卓操作系统 （标题栏苹果为44px,安卓为48px）
				if (res['system'].indexOf('Android') > 0) {
					titleH = 48
				} else {
					titleH = 46
				}
				this.headerTop = titleH + res['statusBarHeight']
				this.pHeight = titleH
				this.tHeight = res['statusBarHeight']
			}
			
			this.bussinid = options.bussinid;//商户id
			
			// 获取商户信息
			this.request({
				url: '/xcx/agentinfo',
				data: {
					agent_id: this.bussinid
				},
				method: "POST"
			}).then(res => {
				if (res.data.code == 200) {
					this.info = res.data.data;
				} else {
					uni.showToast({
						title: res.data.message,
						icon: 'none'
					})
				}
			})
		},
		methods: {
			tingzhi(){
				this.request({
					url: '/agent/editbussiness',
					data: {
						bussinessid: this.bussinid,
						divided: 0,
						dividedstatus: 0,
						dividedline: 0,
						dividedbox: 0,
					},
					method: "POST"
				}).then(res => {
					if (res.data.code == 200) {
						uni.showToast({
							title: '成功',
							icon: 'none'
						})
						
						setTimeout(function(){
							uni.navigateBack()
						},2000)
					} else {
						uni.showToast({
							title: res.data.message,
							icon: 'none'
						})
					}
				})
			},
			topage(url){
				uni.navigateTo({
					url
				})
			},
			fanhui() {
				uni.navigateBack();
			}
		}
	}
</script>

<style lang="scss" scoped>
	.store {
		width: 100%;
		margin: 0 auto;
		height: 100vh;
		background: #f9f9ff;
		overflow-y: scroll;

		.head {
			width: 100%;
			position: fixed;
			top: 0;
			left: 0;
			z-index: 99;
			background: linear-gradient(90deg, #f9f9ff, #d4e8ff);

			.xztitle {
				position: fixed;
				left: 0%;
				top: 0;
				width: 100%;
				text-align: left;
				color: #333333;
				font-size: 32rpx;
				padding-left: 74rpx;
				font-weight: 700;

				.iconfont {
					position: absolute;
					top: 0;
					left: 30rpx;
					font-size: 44rpx;
				}
			}
		}

		.headtop {
			width: 100%;
			background: linear-gradient(90deg, #f9f9ff, #d4e8ff);
			height: 300rpx;
			padding: 20rpx 40rpx 0;
			box-sizing: border-box;
		}
		
		.nr{
			width: 90%;
			margin: 0 auto;
			z-index: 70;
			margin-top: -280rpx;
			background: #fff;
			box-shadow: rgba(223, 230, 255, 0.67) 0px 0px 6px;
			
			.list{
				width: 100%;
				border-radius: 20rpx;
				margin-bottom: 20rpx;
				padding: 40rpx 40rpx 10rpx;
				position: relative;
				
				.liebiao{
					margin-bottom: 30rpx;
					
					.left{
						font-size: 24rpx;
						color: #333333;
						width: 50%;
					}
					
					.right{
						
						.title{
							font-size: 24rpx;
							color: #333333;
						}
						
						.name{
							font-size: 24rpx;
							color: #5C88FA;
						}
					}
				}
			}
			
			.footer{
				width: 100%;
				margin-bottom: 20rpx;
				padding: 0 40rpx 40rpx;
				
				.left{
					width: 30%;
					height: 60rpx;
					line-height: 60rpx;
					text-align: center;
					font-size: 28rpx;
					border-radius: 16rpx;
					color: #333333;
					background: #F0F0F0;
					margin-left: 40rpx;
				}
				
				.right{
					width: 30%;
					height: 60rpx;
					line-height: 60rpx;
					text-align: center;
					font-size: 28rpx;
					border-radius: 16rpx;
					color: #FFFFFF;
					background: #3B91F8;
					margin-right: 40rpx;
				}
			}
		}
	}
</style>